﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace UBCon.Ribbon.SkinManagers
{
    /// <summary>
    /// Represents a class that manages Office2007 skin.
    /// </summary>
    internal class Office2007SkinManager
    {
        private const string stringFormat = "/UBCon.Ribbon;component/Themes/Office{0}Skin/{1}.xaml";

        private ResourceDictionary ribbonChrome,
                                   applicationMenu,
                                   //contextualTabItemsGroup,
                                   //dropDownMenuItem,
                                   //qAToolbar,
                                   ribbonBar,
                                   //ribbonComboBox,
                                   //ribbonComboBoxItem,
                                   //ribbonDropDownButton,
                                   //ribbonGallery,
                                   //ribbonGalleryItem,
                                   //ribbonGroup,
                                   //ribbonSplitButton,,
                                   ribbonButton,
                                   ribbonTabItem,
                                   //ribbonToggleButton,
                                   colorResource,
                                   ribbonWindow;

        /// <summary>
        /// 
        /// </summary>
        internal const int Version = 2007;

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.RibbonChrome control.
        /// </summary>
        internal ResourceDictionary RibbonChrome 
        {
            get 
            {
                if (ribbonChrome == null) 
                {
                    ribbonChrome = new ResourceDictionary() 
                    { 
                        Source = new Uri(string.Format(stringFormat, Version, "RibbonChrome"), UriKind.Relative) 
                    };
                }
                return ribbonChrome;
            }
        }

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.ApplicationMenu control.
        /// </summary>
        internal ResourceDictionary ApplicationMenu 
        {
            get 
            {
                if (applicationMenu == null)
                {
                    applicationMenu = new ResourceDictionary() 
                    { 
                        Source = new Uri(string.Format(stringFormat, Version, "ApplicationMenu"), UriKind.Relative) 
                    };
                }
                return applicationMenu;
            }
        }

        /// <summary>
        /// Gets a resource file that contains brushes and images for Office 2007 skin.
        /// </summary>
        internal ResourceDictionary ColorResources
        {
            get 
            {
                if (colorResource == null) 
                {
                    colorResource = new ResourceDictionary() 
                    {
                        Source = new Uri(string.Format(stringFormat, Version, string.Format("Office{0}Resources", Version)), UriKind.Relative) 
                    };
                }

                return colorResource;
            }
        }

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.RibbonWindow control.
        /// </summary>
        internal ResourceDictionary RibbonWindow 
        {
            get 
            {
                if (ribbonWindow == null)
                {
                    ribbonWindow = new ResourceDictionary() 
                    { 
                        Source = new Uri(string.Format(stringFormat, Version, "RibbonWindow"), UriKind.Relative) 
                    };
                }
                return ribbonWindow;
            }
        }

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.RibbonTabItem control.
        /// </summary>
        internal ResourceDictionary RibbonTabItem 
        {
            get 
            {
                if (ribbonTabItem == null) 
                {
                    ribbonTabItem = new ResourceDictionary() 
                    { 
                        Source = new Uri(string.Format(stringFormat, Version, "RibbonTabItem"), UriKind.Relative) 
                    };
                }
                return ribbonTabItem;
            }
        }

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.RibbonButton control.
        /// </summary>
        internal ResourceDictionary RibbonButton 
        {
            get 
            {
                if (ribbonButton == null) 
                {
                    try
                    {
                        ribbonButton = new ResourceDictionary()
                        {
                            Source = new Uri(string.Format(stringFormat, Version, "RibbonButton"), UriKind.Relative)
                        };
                    }
                    catch 
                    {
                    
                    }
                }
                return ribbonButton;
            }
        }

        /// <summary>
        /// Gets a resource file that contains templates and styles for the UBCon.Ribbon.RibbonBar control.
        /// </summary>
        internal ResourceDictionary RibbonBar
        {
            get
            {
                if (ribbonBar == null)
                {
                    ribbonBar = new ResourceDictionary()
                    {
                        Source = new Uri(string.Format(stringFormat, Version, "RibbonBar"), UriKind.Relative)
                    };
                }
                return ribbonBar;
            }
        }

    }
}
